#include "control.h"

/*
 * Creates an update loop that doesn't hog cpu
 * and quits when running is set to false
 */
void bt::InitMainLoop(void (*UpdateFunc)(void), Uint32 refreshRate, bool& running)
{
	running = true;
	
	Uint32 lastFrameTime = 0;
	Uint32 now;
	
	while(running)
	{
		now = SDL_GetTicks();
		if((lastFrameTime - now) < refreshRate)
		{	/* Conserve CPU */
			SDL_Delay(5);
		}
		
		UpdateFunc();
	}
}

